package user;

import Dao.communityDao;
import Dao.communityDaoImpl;
import been.Health;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

@WebServlet(value = "/findAllHealthInformation")
public class findAllHealthInformationServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        communityDao dao = new communityDaoImpl();
        ArrayList<Health> healthList=new ArrayList<>();
        try {
            healthList= (ArrayList<Health>) dao.findAllHealthByHealthId();
            request.setAttribute("healthList", healthList);
            request.getRequestDispatcher("/WEB-INF/user/findAllHealthInformation.jsp").forward(request,response);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
